import memcache

# TODO: 链接memcached
mc = memcache.Client(servers=['192.168.184.142:11211'], debug=True)

# TODO: 设置数据
# mc.set('username', 'zhiliao', time=120)
mc.set_multi({'username': 'zhiliao', 'country': 'china', 'age': 18}, time=120)

# TODO: 获取数据
# username = mc.get('username')
# print(username)
# country = mc.get('country')
# print(country)

# TODO: 删除数据
# username = mc.get('username')
# print(username)
# mc.delete('username')
#
# username = mc.get('username')
# print(username)

# TODO: 自增长
# print(mc.get('age'))
# mc.incr('age')

# TODO: 自增长指定数值
# mc.incr('age', delta=10)
# print(mc.get('age'))

# TODO: 自减少
print(mc.get('age'))
# mc.decr('age')

# TODO: 自减少指定数值
mc.decr('age', delta=10)
print(mc.get('age'))
